﻿//show_all_markers.sqf
#include "ACV_constantes.h"
#include "ACV_ID_main_dlg.h"

private ["_display","_btn_show","_map","_pos","_name","_marker","_color"];

disableserialization;
_display = uiNamespace getVariable "R3F_ACV_MAIN_DLG";
_btn_show = _display displayCtrl ACV_DLG_ID_Main_CbShowAll;
_map =  _display displayCtrl ACV_DLG_ID_Main_Map;

ACV_Show_All_Markers = !ACV_Show_All_Markers;

if (!ACV_Show_All_Markers) then {
	{	deleteMarkerLocal _x;
	} foreach ACV_ARRAY_MARKERS;
} else {
	ACV_Unit_Stock =  Server getVariable "ACV_Unit_Stock";
	ACV_Object_Stock =  Server getVariable "ACV_Object_Stock";

	{	_name = format["SH_%1",(_x getVariable "VarName")];
		_pos = (getpos leader _x);

		_marker = createMarkerLocal [_name,_pos];
		_marker setMarkerShapeLocal "ICON";
		_marker setMarkerTypeLocal "mil_dot";
		_marker setMarkerPosLocal _pos;
		_marker setMarkerSizeLocal [0.5,0.5];
		_marker setMarkerTextLocal (_x getVariable "Name");
		_marker setMarkerColorLocal ([_x] call R3F_FNCT_GetMarkerColor);
		_marker  setMarkerAlphaLocal 0.5;
		ACV_ARRAY_MARKERS set [(count ACV_ARRAY_MARKERS),_marker];
	} foreach ACV_Unit_Stock;

	{	_name = format["SH_%1",(_x getVariable "VarName")];
		_pos = (getpos _x);

		_marker = createMarkerLocal [_name,_pos];
		_marker setMarkerShapeLocal "ICON";
		_marker setMarkerTypeLocal "mil_dot";
		_marker setMarkerPosLocal _pos;
		_marker setMarkerSizeLocal [0.5,0.5];
		_marker setMarkerTextLocal (_x getVariable "Name");
		_marker setMarkerColorLocal "ColorYellow";
		_marker  setMarkerAlphaLocal 0.5;
		ACV_ARRAY_MARKERS set [(count ACV_ARRAY_MARKERS),_marker];
	} foreach ACV_Object_Stock;
};
if (ACV_Show_All_Markers) then {
	_btn_show ctrlSetText "--";
	_btn_show ctrlSetTooltip localize "STR_TOOLTIP_HIDEMARKERS";
} else {
	_btn_show ctrlSetText Localize "STR_ACV_BTN_LOOK";
	_btn_show ctrlSetTooltip localize "STR_TOOLTIP_SHOWMARKERS";
};
